#include "PlayerControl.h"

PlayerControl::PlayerControl(QWidget *parent) : QWidget(parent){
	m_layout = new QHBoxLayout(this);
	setLayout(m_layout);

	m_buttonPrev = new QPushButton("Prev", this);
	m_layout->addWidget(m_buttonPrev);
	connect(m_buttonPrev, SIGNAL(clicked()), this, SLOT(slotPrev()));

	m_buttonPlayPause = new QPushButton("Play", this);
	m_layout->addWidget(m_buttonPlayPause);
	connect(m_buttonPlayPause, SIGNAL(clicked()), this, SLOT(slotPlay()));

	m_buttonStop = new QPushButton("Stop", this);
	m_layout->addWidget(m_buttonStop);
	connect(m_buttonStop, SIGNAL(clicked()), this, SLOT(slotStop()));

	m_buttonNext = new QPushButton("Next", this);
	m_layout->addWidget(m_buttonNext);
	connect(m_buttonNext, SIGNAL(clicked()), this, SLOT(slotNext()));
}

void PlayerControl::slotPrev(){
	emit prev();
}

void PlayerControl::slotPlay(){
	emit play();
}

void PlayerControl::slotPause(){
	emit pause();
}

void PlayerControl::slotStop(){
	emit stop();
}

void PlayerControl::slotNext(){
	emit next();
}
#include<stdio.h>
void PlayerControl::slotPlaying(){
	m_buttonPlayPause->disconnect();
	connect(m_buttonPlayPause, SIGNAL(clicked()), this, SLOT(slotPause()));
	m_buttonPlayPause->setText("Pause");
	printf("...\n");
}

void PlayerControl::slotPaused(){
	m_buttonPlayPause->disconnect();
	connect(m_buttonPlayPause, SIGNAL(clicked()), this, SLOT(slotPlay()));
	m_buttonPlayPause->setText("Play");
	printf("...\n");
}

void PlayerControl::slotStopped(){
	m_buttonPlayPause->disconnect();
	connect(m_buttonPlayPause, SIGNAL(clicked()), this, SLOT(slotPlay()));
	m_buttonPlayPause->setText("Play");
	printf("...\n");
}
